prepare-root: Fix crash if no valid signatures
authorAlexander Larsson <alexl@redhat.com>
Mon, 20 Oct 2025 10:26:50 +0000 (12:26 +0200)
committerAlexander Larsson <alexl@redhat.com>
Mon, 20 Oct 2025 10:26:50 +0000 (12:26 +0200)
We didn't set error if there were zero valid signatures, which caused
a crash prefixing the error. While fixing this, the error messages were
slightly reworded to make it nicer.

src/libotcore/otcore-prepare-root.c

index a628b88030d949539690bb037560ede32c850bea..89844f03ee629fff48bfd3826610b12e930b241e 100644 (file)
@@ -419,7 +419,7 @@ validate_signature (GBytes *data, GVariant *signatures, GPtrArray *pubkeys, GErr
         }
     }
 
-  return FALSE;
+  return glnx_throw (error, "No valid (of %" G_GSIZE_FORMAT ") signatures found", g_variant_n_children (signatures));
 }
 
 // Output a friendly message based on an errno for common cases
@@ -641,7 +641,7 @@ otcore_mount_rootfs (RootConfig *rootfs_config, GVariantBuilder *metadata_builde
 
       g_autoptr (GBytes) commit_data = g_variant_get_data_as_bytes (commit);
       if (!validate_signature (commit_data, signatures, rootfs_config->pubkeys, error))
-        return glnx_prefix_error (error, "No valid signatures found for public key");
+        return glnx_prefix_error (error, "Checking commit signature");
 
       ot_journal_print (LOG_INFO, "composefs+ostree: Validated commit signature using '%s'",
                         composefs_pubkey);